package org.grottarossa.data.impl;

import javax.jdo.PersistenceManager;

import org.grottarossa.data.TaskDAO;
import org.grottarossa.domain.Task;

public class TaskDAOImpl extends GenericDAO implements TaskDAO
{

	@Override
	public String createTask(Task task) 
	{
		PersistenceManager pm = this.persistenceManagerFactory
				.getPersistenceManager();
		Task taskF = null;
		try {
			pm.currentTransaction().begin();
			
			taskF = pm.makePersistent(task);
			
			pm.currentTransaction().commit();
		} catch (Exception e) {
			// TODO cath exception
			pm.currentTransaction().rollback();
		} finally {
			if (pm.currentTransaction().isActive()) {
				pm.currentTransaction().rollback();
			}
			pm.close();
		}
		return taskF.getId();
	}

	@Override
	public void updateTask(Task task) 
	{
		
	}

	@Override
	public void removeTask(Task task) 
	{
		
	}

	@Override
	public Task findTaskById(String task_id) 
	{
		return null;
	}
}
